import threading
class DiningPhilosophers:
    def __init__(self):
        self.fork = threading.Condition()
        self.d = [{0,7,8},{0,8,9},{0,9,5},{0,5,6},{0,6,7}]
        self.t = 0
    # call the functions directly to execute, for example, eat()
    def wantsToEat(self,
                   philosopher: int,
                   pickLeftFork: 'Callable[[], None]',
                   pickRightFork: 'Callable[[], None]',
                   eat: 'Callable[[], None]',
                   putLeftFork: 'Callable[[], None]',
                   putRightFork: 'Callable[[], None]') -> None:
        with self.fork:
            self.fork.wait_for(lambda : self.t in self.d[philosopher])
            self.t += philosopher + 5
            self.fork.notify_all()
        pickLeftFork()
        pickRightFork()
        eat()
        putLeftFork()
        putRightFork()
        with self.fork:
            self.t -= (philosopher + 5)
            self.fork.notify_all()
        

